<div class="row">
	<div class="col-sm-12" style="width: 99%;">
		<div class="nest" id="treeClose">
			<div class="title-alt">
				<h6>CHI TIẾT THIẾT BỊ</h6>
			</div>

			<div class="body-nest" id="tree" style="min-height: 490px">
    				<div class="row">
                        <div class="col-sm-5" style="width:100%;">
						<div class="nest" id="validationClose">
						<label class="control-label" for="subject">Chi tiết của thiết bị này</label><br/>
						Địa chỉ : <?php echo $devicedetail->address;?><br/>
						MAC : <?php echo $devicedetail->mac;?><br/>
						Nasid : <?php echo $devicedetail->nasid;?><br/>
						Trạng thái : <?php if( $devicedetail->active == 1 ){ echo 'Hoạt động';}else{ echo 'Không hoạt động';} ?><br/>
						</div>
                        <div class="nest" id="validationClose">
                           
                            <div class="body-nest" id="validation">
                                <div class="form_center" style="width: 70%;float:left;">
                                    <?php if(validation_errors() || @$error || @$zero):?>
                                    <div class="alert alert-danger">
                                        <button data-dismiss="alert" class="close" type="button">×</button>
                                        <span class="entypo-attention"></span>
                                        <strong>Oh lỗi!</strong>&nbsp;&nbsp;<?php echo validation_errors(); ?>
                                        <?php if(@$error):?>
                                        <br />
                                        <?php echo $error?>
                                        <?php endif;?>
                                        <?php if(@$zero):?>
                                        <br />
                                        <?php endif;?>
                                    </div>
                                    <?php endif;?>
                                    <?php if(@$status):?>
                                       
                                    <?php endif;?>
                                    <?php $att = array('id' => 'contact-form', 'class' => 'form-horizontal'); echo form_open('', $att);?>
                                        <fieldset>
                                            <div class="control-group">
                                                <div class="controls">
                                                    <textarea row="5" class="form-control" value="<?php echo $this->input->post('content');?>" name="content" id="lng" placeholder="Viết ghi chú..." /></textarea>
                                                </div>
                                            </div>
                                            <div class="form-actions" style="margin:20px 0 0 0;float: left;">
                                                <button type="submit" class="btn btn-primary">Gửi đi</button>
                                            </div>
                                        </fieldset>
                                    </form>
                                </div>
                            </div>
                        </div>
						<div class="nest" id="validationClose">
							<p style="font-weight: bold;margin-top: 20px;float: left;width: 100%;font-size: 14px;">Danh sách ghi chú cũ</p>
							<ul style="list-style: none;margin-top: 10px;line-height: 28px;float: left;">
								<?php foreach ( $devicedetail->comment AS $el=>$le ){ ?> 
								<li style="  border-bottom: 1px solid rgb(234, 234, 234); margin-bottom: 20px;"><b>Người đăng : Admin, Ngày đăng <?php echo date('H:i:s d-m-Y',strtotime($le->created));?></b><br/>  
								Trạng thái : <?php if( $le->active == 1 ){ echo '<span style="color:red;">Chưa xử lý</span>';}else{
									echo '<span style="color:blue;">Đã xử lý</span>';
								}?><br/>
								<?php echo $le->content;?><br/>
							<button type="submit" id="<?php echo $le->id;?>-<?php echo $le->active;?>" class="btn btn-primary btn-update">Cập nhật</button><br/><br/>
								</li>
								<?php } ?>
							</ul>
						</div>
						
                    </div>
    			</div>
			</div>
		</div>
	</div>
    <style>
    #pagination{
    }
    #pagination a{
            padding: 3px 10px;
            margin: 10px 2px;
            border: 1px solid #CCC;
            background: #CCC;
            color: #FFF;
    }
    #pagination strong{
            padding: 3px 10px;
            margin: 10px 2px;
            border: 1px solid #CCC;
    }
    #box-map{
        float: right !important;width: 348px;margin: 15px;margin-right: 0px;
    }
    </style>
</div>
<script>
$('.btn-update').click(function(){
	val = this.id;
	$.ajax({
		type:"GET",
		url: '<?php echo $baseurl.'ajax-update-comment';?>',
		data:{   
			val: val
		},
		success:function(data){
			if( data == '200' ){
				alert('Cập nhật thành công');
				window.location.href='<?php echo $baseurl.'device-detail/'.$id;?>';
			}else{
				alert('Thất bại'); return false;
			}
		}
	});
});

</script>
